//
//  BJYDownlodingCell.m
//  JW_BasePorject
//
//  Created by JW on 2018/7/3.
//  Copyright © 2018年 JW. All rights reserved.
//

#import "BJYDownlodingCell.h"
#import "PMDownloadModel+ZYVideo.h"
#import "ZZCircleProgress.h"
@interface BJYDownlodingCell ()

@property (nonatomic, strong)UILabel *titleLabel;

@property (nonatomic, strong)UILabel *detailsLabel;

@property (nonatomic, strong)ZZCircleProgress *progressView;

@end

@implementation BJYDownlodingCell

- (void)setPM_model:(PMDownloadModel *)PM_model{
    _PM_model = PM_model;
    self.titleLabel.text = PM_model.section_name;
    self.detailsLabel.text = [NSString stringWithFormat:@"时长%f分钟 | 大小%@",PM_model.duration/60,PM_model.zy_videoSize];
    self.progressView.progress = 0.30;
}

- (void)addChildViews{
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.detailsLabel];
    [self.contentView addSubview:self.detailsLabel];
}

+ (BJYDownlodingCell *)cellWithTableView:(UITableView *)tableView{
    static NSString *ident = @"BJYCacheVideoCell";
    BJYDownlodingCell *cell = [tableView dequeueReusableCellWithIdentifier:ident];
    if (!cell) {
        cell = [[BJYDownlodingCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ident];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
    
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addChildViews];
    }
    return  self;
}

- (UILabel *)titleLabel{
    if (_titleLabel == nil) {
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, SCREEN_WIDTH - 120, 20)];
        _titleLabel.font = [UIFont systemFontOfSize:16];
        _titleLabel.numberOfLines = 0;
    }
    return _titleLabel;
}

- (UILabel *)detailsLabel{
    if (_detailsLabel == nil) {
        _detailsLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 30, SCREEN_WIDTH - 120, 10)];
        _detailsLabel.font = [UIFont systemFontOfSize:13];
        _detailsLabel.textColor = [UIColor grayColor];
    }
    return _detailsLabel;
    
}

- (ZZCircleProgress *)progressView{
    if (_progressView == nil) {
        _progressView = [[ZZCircleProgress alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 60, 10, 40, 40) pathBackColor:[UIColor lightGrayColor] pathFillColor:ZhuTiColor startAngle:0 strokeWidth:5];
        _progressView.prepareToShow = YES;//设置完进度条相关属性后需要设置此属性为YES，否则设置progress之前进度条不显示。
    }
    return _progressView;
}
@end
